package com.rw.coco;

import com.rw.coco.api.bot.CocoApi;
import com.rw.coco.api.data.CocoDataApi;
import com.rw.coco.api.reply.CocoReplyApi;
import com.rw.coco.data.FileCocoDataApi;
import com.rw.coco.listener.CocoGroupListener;
import com.rw.coco.listener.CocoPrivateListener;
import com.rw.coco.logger.KookLogger;
import com.rw.coco.reply.PropertiesCocoReplyApi;
import snw.jkook.plugin.BasePlugin;

public class CocoPlugin extends BasePlugin {
    public static final String WORK_PATH = "E:\\RWdaze\\Test\\Coco\\";

    // 插件运行实例
    private static CocoPlugin instance;

    /**
     * 获取插件运行实例
     */
    public static CocoPlugin getInstance() {
        return instance;
    }

    @Override
    public void onEnable() {
        instance = this;
        // 创建可可日志类
        KookLogger logger = new KookLogger(getLogger());
        // 创建可可数据交互API
        CocoDataApi fileDataApi = new FileCocoDataApi(WORK_PATH);
        // 创建可可回复来源
        CocoReplyApi replyApi = new PropertiesCocoReplyApi(logger);
        // 创建可可对象
        CocoApi coco = new Coco(fileDataApi, replyApi, logger);

        // 注册群聊消息
        getCore().getEventManager().registerHandlers(this, new CocoGroupListener(coco));
        // 注册私聊消息
        getCore().getEventManager().registerHandlers(this, new CocoPrivateListener(coco));
    }
}
